feat(cli): Add ui5 cache clean command - #1455
Conversation
2195d0e to
979a629
Compare
979a629 to
cc367f3
Compare
Adds `ui5 cache clean` to remove framework packages and build cache data. Displays what will be removed with library/version stats, asks for confirmation (skip with --yes), and handles orphaned staging dirs from previously interrupted cleans. No process-coordination locks — that will be added separately.
f332519 to
89e915f
Compare
28454d6 to
a0444d5
Compare
e35f673 to
af2b848
Compare
3ead788 to
db2912e
Compare
db2912e to
c4e20b3
Compare
For tables big enough, it could take a lot of time to run the VACUUM. For that reason, do the same as the directory rename- rename tables and later clean them up. This will not corrupt Db data and will be able to resume if the process is killed
cc944d7 to
5c27a35
Compare
5c27a35 to
bcaa7fa
Compare
301caa6 to
0e631fa
Compare
|
Note: When I run |
| } | ||
|
|
||
| /** | ||
| * Comma separated list of components to which orphaned resources should be added. |
There was a problem hiding this comment.
I don't think we should rename this term here. The class has a createOrphanFilters, so I would propose that we do not change this.
| * @returns {number} Database size in bytes before the drop (pending reclamation after vacuum) | ||
| */ | ||
| dropAllRecords() { | ||
| const tables = ["content", "index_cache", "stage_metadata", "task_metadata", "result_metadata"]; |
There was a problem hiding this comment.
Same array values as above, so they need to stay in sync. Why not extracting this into a constant for all table names? Maybe we need it also somewhere else in future.
| this.#db.exec("VACUUM"); | ||
| this.#db.exec("UPDATE _vacuum_pending SET pending = 0 WHERE rowid = 1"); |
There was a problem hiding this comment.
Shouldn't this also be an transaction?
| * @param {string} ui5DataDir Resolved absolute path to UI5 data directory | ||
| * @returns {Promise<{path: string, size: number}|null>} Build cache info or null | ||
| */ | ||
| static async getCacheInfo(ui5DataDir) { |
There was a problem hiding this comment.
This and the next three methods are almost identical, and it doesn't look like it would be too complex to refactor them into a common method that can be used for the individual ones, without creating more complexity.
| * The directory is renamed to this prefix + a random hex suffix before deletion so that | ||
| * the original path is immediately removed and the deletion can proceed outside the rename. | ||
| */ | ||
| const STAGING_DIR_PREFIX = "_framework_to_delete_"; |
There was a problem hiding this comment.
We should use a different term than staging here as there is already a staging dir for downloading the framework libraries (.ui5/framework/staging), which can be confusing as they are fundamentally different. At least an addition, like "removal" or "delete" or something would help to identify that they are not the same.
This PR introduces a new cache cleanup workflow for UI5 CLI via the
ui5 cache cleancommand, including safer cleanup semantics, clearer user output, and recovery of leftovers from interrupted cleanup runs.Why
Current cache cleanup requires manual directory deletion, which is error-prone and not ideal for CI or scripted usage.
This change provides a first-class command that:
Explains what will be removed before execution.
Supports non-interactive execution.
Handles stale cache artifacts from interrupted previous runs.
JIRA: CPOUI5FOUNDATION-891